//
//  CCCamera.h
//  ShadowMapping
//
//  Created by Daniel Corleone on 18/6/14.
//  Copyright (c) 2014年 iCloverStudio. All rights reserved.
//

#ifndef __ShadowMapping__CCCamera__
#define __ShadowMapping__CCCamera__

#include "CCNode.h"
#include "PlatformConfig.h"

BECO_NAMESPACE_BEGIN

class Camera
    : public Node
{
public:
    typedef enum {
        CAMERA_TYPE_ORTHO = 0,
        CAMERA_TYPE_PERSPECTIVE = 1,
    } Camera_Type;
    
public:
    explicit Camera(const String& name, Camera_Type _type = CAMERA_TYPE_PERSPECTIVE);
    explicit Camera(Node* parent, const String& name, Camera_Type _type = CAMERA_TYPE_PERSPECTIVE);
    ~Camera();
    
public:
    virtual void Update(const Real timeInterval);
    virtual void Render(const Real timeInterval);
    
public:
    CC_INLINE void setupPerspective(const Real angle, const Real aspectRatio, const Real near, const Real far);
    CC_INLINE void setupLookat(const Real eyeX, const Real eyeY, const Real eyeZ, const Real targetX, const Real targetY, const Real targetZ, const Real upX, const Real upY, const Real upZ);
    
    CC_INLINE glm::vec3 getTarget(void) const;
    CC_INLINE glm::vec3 getCameraPosition(void) const;
    CC_INLINE glm::vec3 getUp(void) const;
    
    CC_INLINE glm::mat4 getProjectMatrix(void) const;
    
private:
    Camera_Type eCameraType;
    
    glm::vec3 vEye;
    glm::vec3 vTarget;
    glm::vec3 vUp;
    
    glm::mat4 matProjection;
    
    Real rAngle;
    Real rAspectRatio;
    Real rNear;
    Real rFar;
};

BECO_NAMESPACE_END

#endif /* defined(__ShadowMapping__CCCamera__) */
